package com.extension.company.view.my.localorder.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.extension.company.admin.R;
import com.extension.company.model.entity.SameCityOrderAllBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;


/**
 * 同城订单---待评价
 */
public class LocalCityUnCommitmentAdapter extends RecyclerView.Adapter<LocalCityUnCommitmentAdapter.ViewHolder> {


	private List<SameCityOrderAllBean> mValues;
	private Context context;

	public LocalCityUnCommitmentAdapter(Context context, List<SameCityOrderAllBean> items) {
		this.mValues = items;
		this.context = context;
	}

	@Override
	public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
		View view = LayoutInflater.from(parent.getContext())
				.inflate(R.layout.fragment_fragmentuncommitment, parent, false);
		return new ViewHolder(view);
	}

	@Override
	public void onBindViewHolder(final ViewHolder holder, int position) {


		holder.commitItemLeft.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				if (null != click) {
					click.orderAgain();
				}
			}
		});
		holder.commitItemRight.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				if (null != click) {
					click.commitImmeditately();
				}
			}
		});
	}

	@Override
	public int getItemCount() {
		return 10;
	}

	public class ViewHolder extends RecyclerView.ViewHolder {

		@BindView(R.id.commit_item_icon)
		ImageView commitItemIcon;
		@BindView(R.id.commit_store_name)
		TextView commitStoreName;
		@BindView(R.id.commit_item_img)
		ImageView commitItemImg;
		@BindView(R.id.commit_item_name)
		TextView commitItemName;
		@BindView(R.id.commit_total_num)
		TextView commitTotalNum;
		@BindView(R.id.commit_total_price)
		TextView commitTotalPrice;
		@BindView(R.id.commit_item_left)
		Button commitItemLeft;
		@BindView(R.id.commit_item_right)
		Button commitItemRight;

		public ViewHolder(View view) {
			super(view);
			ButterKnife.bind(this, view);
		}


	}


	public interface OnListFragmentInteractionListener {
		void orderAgain();  // 在来一单

		void commitImmeditately();  // 立即评论
	}

	private OnListFragmentInteractionListener click;

	public void setRCYOnclick(OnListFragmentInteractionListener click) {
		this.click = click;
	}

}
